package com.dtjd.playcoinmonkey.activities;

import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;

import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

import com.dtjd.playcoinmonkey.adapter.AdminAdapter;
import com.dtjd.playcoinmonkey.bean.MeListBean;
import com.dtjd.playcoinmonkey.databinding.ActivityAdminBinding;

import java.util.ArrayList;import com.dtjd.playcoinmonkey.R;
import java.util.List;

public class AdminActivity extends AppCompatActivity {

    private final List<MeListBean> data=new ArrayList<>();

    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        if (android.R.id.home==item.getItemId()){ finish(); }
        return super.onOptionsItemSelected(item);
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        com.dtjd.playcoinmonkey.databinding.ActivityAdminBinding binding = ActivityAdminBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        ActionBar actionbar = getSupportActionBar();
        if (actionbar!=null){
            actionbar.setDisplayHomeAsUpEnabled(true);
            actionbar.setHomeButtonEnabled(true);
        }
        setTitle(getResources().getString(R.string.admin));
        AdminAdapter adp = new AdminAdapter(this, data);
        binding.adminList.setAdapter(adp);
        binding.adminList.setOnItemClickListener((adapterView, view, i, l) -> {
            MeListBean bean = data.get(i);
            if (bean.cmd.equals("tipoff")){
                startActivity(new Intent(AdminActivity.this,ManageTipOffActivity.class));
            }
            if (bean.cmd.equals("frozen")){
                startActivity(new Intent(AdminActivity.this,ManageFrozenActivity.class));
            }
            if (bean.cmd.equals("warning")){
                Intent intent=new Intent(AdminActivity.this,ManageNoticeActivity.class);
                intent.putExtra("type","warning");
                startActivity(intent);
            }
            if (bean.cmd.equals("notice")){
                Intent intent=new Intent(AdminActivity.this,ManageNoticeActivity.class);
                intent.putExtra("type","notice");
                startActivity(intent);
            }
            if (bean.cmd.equals("recommend")){
                startActivity(new Intent(AdminActivity.this,ManageRecommendActivity.class));
            }
            if (bean.cmd.equals("ticket")){
                startActivity(new Intent(AdminActivity.this,AddTicketActivity.class));
            }
        });
        data.add(new MeListBean(R.drawable.warn,getResources().getString(R.string.warn),getResources().getString(R.string.modifyWarning),true,"warning",1,false));
        data.add(new MeListBean(R.drawable.notice,getResources().getString(R.string.notice),getResources().getString(R.string.modifynotice),true,"notice",1,false));
        data.add(new MeListBean(R.drawable.recommend,getResources().getString(R.string.recommend),getResources().getString(R.string.modifyRecommend),true,"recommend",1,false));
        data.add(new MeListBean(R.drawable.ticket,getResources().getString(R.string.ticket),getResources().getString(R.string.modifyTicket),true,"ticket",1,false));
        data.add(new MeListBean(R.drawable.tipoff,getResources().getString(R.string.tip_off),getResources().getString(R.string.tip_off_admin),true,"tipoff",1,false));
        data.add(new MeListBean(R.drawable.frozen,getResources().getString(R.string.frozen),getResources().getString(R.string.frozenAdmin),true,"frozen",1,false));
    }
}